package com.hualan.sfzy.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzy.constant.CommonConstant;
import com.hualan.sfzy.mapper.ConsultNoticeMapper;
import com.hualan.sfzy.model.entity.CharityCenter;
import com.hualan.sfzy.model.entity.ConsultNotice;

import com.hualan.sfzy.service.ConsultNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 咨询通知服务实现类
 */
@Service
public class ConsultNoticeServiceImpl implements ConsultNoticeService {
    @Autowired
    private ConsultNoticeMapper consultNoticeMapper;

    @Override
    public int add(ConsultNotice entity) {
        return consultNoticeMapper.insert(entity);
    }

    @Override
    public int edit(ConsultNotice entity) {
        return consultNoticeMapper.update(entity);
    }

    @Override
    public int remove(Integer id) {
        return consultNoticeMapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return consultNoticeMapper.deleteBatch(ids);
    }

    @Override
    public List<ConsultNotice> find() {
        return consultNoticeMapper.select(new ConsultNotice());
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, ConsultNotice entity) {
        PageHelper.startPage(pageNum, pageSize);
        List<ConsultNotice> list = consultNoticeMapper.select(entity);
        PageInfo<ConsultNotice> pageInfo = new PageInfo<>(list);
        Map<String, Object> pageMap = new HashMap<>();
        pageMap.put(CommonConstant.PAGE_LIST, list);
        pageMap.put(CommonConstant.PAGE_TOTAL, pageInfo.getPages());
        pageMap.put(CommonConstant.TOTAL, pageInfo.getTotal());
        return pageMap;
    }

    @Override
    public ConsultNotice findById(Integer id) {
        return consultNoticeMapper.selectById(id);
    }
}